package test;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import javax.swing.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;

public class test {
    public static void main(String[] args) throws Exception {
        boolean flag=true;
        String s="llx";
        String h="11111";
        Properties properties=new Properties();
        properties.load(new FileInputStream("src/druid.properties"));
        DataSource dataSource= DruidDataSourceFactory.createDataSource(properties);
        Connection connection=dataSource.getConnection();
        String sql="select password,password from user ";
        PreparedStatement preparedStatement=connection.prepareStatement(sql);
        ResultSet resultSet=preparedStatement.executeQuery();
        while(resultSet.next()){
            if(resultSet.getString("username").trim().equals(s)&&resultSet.getString("password").trim().equals(h)){
                flag=false;
                System.out.println("yes");
            }
        }
        if(flag) System.out.println("off");
        resultSet.close();
        preparedStatement.close();
        connection.close();
    }
}
